<?php $this->load->view('common/default_header.php');?>
<?php $this->load->view('common/invite_nav.php');?>
<section>
    <div class="relubox" style="border: none;">
        <?php if($user_info['invite_flag']==0){?>
        <div><img src="<?php echo img_url("/wcp/banar.jpg");?>" width="100%"/></div>
        <?php }else{?>
        <div><img src="<?php echo img_url("/wcp/banar2.jpg");?>" width="100%"/></div>
        <?php }?>
        <p class="title">产品优势</p>
        <p>要点啥微盘在同类平台中交易品种最为丰富，覆盖了新华A50指数、道琼斯指数、黄金和原油等国际主流品种。要点啥微盘有交易门槛低、简单易上手的特点，只需10元即可交易，操作简单一目了然。另外要点啥微盘出入金最为简便，用户可使用微信支付和银行卡来进行充值与提现操作。</p>
        <p class="title">如何成为经纪人</p>
        <p>要点啥微盘为经纪人提供了高达交易额1%的手续费提成，约合每手0.1元（每手交易额为10元），用户只需要在公众号内申请即可成为要点啥微盘的经纪人，轻松开启财富之门。</p>
        <p class="title">推广方式</p>
        <p>要点啥微盘为每个账户都生成了独一无二的推荐二维码。您只需让新用户扫描自己的推荐二维码，关注并注册要点啥微盘，即推荐成功。另外您还可以将二维码印成宣传单或海报进行分发或粘贴，也可将自己的推荐二维码在互联网上进行传播。任何关注要点啥微盘的新用户都将会得到一张10元交易体验券！</p>
        <p class="title">提成领取</p>
        <p>只要推荐的新用户有交易产生就可得到相应的提成，手续费提成会在每天0点后自动发放到您的交易账户。您可以在推荐人后台查看所有推荐和交易记录。如需提现可进入微操盘申请。</p>
        <div class="reg-btn">
        <?php 
        if($tobemaster==2){
        ?>
            <a href="javascript:showRegDialog()" class="btn btn-block btn-lg btn-warning">注册经纪人</a>
        <?php 
        }else if($tobemaster==1){
          if(!empty($user_info)){
        ?>
          <a href="/invite?tobemaster=1" class="btn btn-block btn-lg btn-warning">注册经纪人</a>
        <?php
          }else{
        ?>
          <a href="javascript:showLoginDialog()" class="btn btn-block btn-lg btn-warning">注册经纪人</a>
        <?php
          }
        }
        ?>    
        </div>
        
    </div>
</section>


<script src="<?php echo js_url("/wcp/jquery-1.9.1.min.js"); ?>?20160329001" type="text/javascript"></script>
<script src="<?php echo js_url("/wcp/bootstrap.min.js"); ?>?20160329001" type="text/javascript"></script>
<script src="<?php echo js_url("/wcp/main.js"); ?>?20160329001" type="text/javascript"></script>
<script src="<?php echo js_url("/wcp/bootstrap-dialog.min.js"); ?>?20160329001" type="text/javascript"></script>
<script src="<?php echo js_url("/wcp/jquery.timers.js"); ?>?20160329001" type="text/javascript"></script>
<script type="text/javascript">

var regHtml = '<form method="post" accept-charset="utf-8" id="regForm" onsubmit="return false;">';
regHtml += '<div class="form-group"><input type="text" name="phone" class="form-control" id="phone" placeholder="手机号码"></div>';
regHtml += '<div class="form-group"><input type="password" name="password" class="form-control" id="password" placeholder="交易密码，4-18位字符"></div>';
regHtml += '<div class="form-group"><input type="password" name="password2" class="form-control" id="password2" placeholder="确认交易密码"></div>';
regHtml += '<div class="form-group"><label><a href="javascript:getSMSCode()" id="getSMSBtn" class="btn btn-warning">获取验证码</a></label></div>';
regHtml += '<div class="form-group"><input type="text" name="vaildCode" class="form-control" id="vaildCode" placeholder="短信验证码"></div>';
regHtml += '<input type="hidden" name="redirect" id="redirect" value="/invite"><a href="javascript:reg()" class="btn btn-block btn-warning">确认</a>';
regHtml += '</form>';

var loginHtml = '<form method="post" accept-charset="utf-8" id="loginForm" onsubmit="return false;">';
loginHtml += '<div class="form-group">';
loginHtml += '<input type="password" name="password" class="form-control" id="password" placeholder="交易密码">';
loginHtml += '</div>';
loginHtml += '<div class="checkbox"><label>';
loginHtml += '<input type="checkbox" name="isFree" class="label-control" id="isFree" value="1">免密码登陆';
loginHtml += '</label></div>';
loginHtml += '<a href="javascript:login()" class="btn btn-block btn-warning">确认</a>';
loginHtml += '<div class="form-group text-center" style="margin-top:15px">';
loginHtml += '<label><a href="javascript:forgotPwd();">忘记交易密码？</a></label>';
loginHtml += '<input type="hidden" name="redirect" id="redirect" value="/invite"></div>';
loginHtml += '</form>';


function showLoginDialog(){
    window.loginDialog = new BootstrapDialog({
        title: '输入交易密码',
        closable:true,
        type: BootstrapDialog.TYPE_DEFAULT,
        message: loginHtml
    });
    window.loginDialog.open();
}

function login(){
    var passwd = $('#loginForm #password').val();
    if(passwd==''){
        myAlert("请输入交易密码");
        return;
    }
    $.ajax({
        type: "POST",
        url: "/api/user/login",
        dataType: 'json',
        data: $("#loginForm").serialize(),
        success: function(data){
            if(data.code==0){
                location.href='/invite?tobemaster=1';
            }else{
                myAlert(data.message);
            }
        },
        error: function(XHR,textStatus,errorThrown) {
            myAlert("无效请求");
        }
    });
}

function getSMSCode(){
  var phone = $.trim($('#phone').val());
  var phoneReg = /^1[0-9]{10}$/;
  if (!phoneReg.test(phone)) {
      myAlert("手机号码输入有误！");
      return;
  }
  var disabled = $("#getSMSBtn").hasClass('disabled');
  if(disabled==undefined||disabled==false){
    $.ajax({
        type: 'POST',
        url: "/ajax/getSMSCode",
        dataType: 'json',
        data: {'type':'reg','area':86,'phone':phone} ,
        success: function(data){
          if(data.errno==0 || data.errno==1){
            countDown($('#getSMSBtn'),data.data.expire);
          }else{
            myAlert(data.msg);
          }
        }
    });
  }else{
    return;
  }
}

//倒计时操作
function countDown($button, time) {
    if (time > 0) {
        $button.addClass('disabled');
        $button.text("重新发送("+time+")");
        setTimeout(function () {
            countDown($button, --time);
        }, 1000);
    } else {
        $button.removeClass('disabled');
        $button.text("获取验证码");
    }
}

function showRegDialog(){
    window.regDialog = new BootstrapDialog({
        title: '用户注册',
        closable:true,
        type: BootstrapDialog.TYPE_DEFAULT,
        message: regHtml
    });
    window.regDialog.open();
}

function reg(){
  var phone = $('#regForm #phone').val();
  if(phone=='') {myAlert("请输入手机号码");return;}
  var password = $('#regForm #password').val();
  if(password=='') {myAlert("请输入交易密码");return;}
  var password2 = $('#regForm #password2').val();
  if(password2=='') {myAlert("请输入确认交易密码");return;}
  var vaildCode = $('#regForm #vaildCode').val();
  if(vaildCode=='') {myAlert("请输入手机验证码");return;}
  $.ajax({
      type: "POST",
      url: "/api/user/register",
      dataType: 'json',
      data: $("#regForm").serialize(),
      success: function(data){
        if(data.code==0){
          location.href='/invite?tobemaster=1';
        }else{
          myAlert(data.message);
        }
      },
      error: function(XHR,textStatus,errorThrown) {
            myAlert("无效请求");
        }
  });
}

</script>








<?php $this->load->view('common/wx_share.php');?>

